import { useRef } from 'react';
import ModalStore from './useModalStore';
import type { ModalProProps } from './type';

const useModal = <T = any>(modal?: ModalProProps<T>) => {
	const modalRef = useRef<ModalProProps<T>>();

	if (modal) {
		modalRef.current = modal;
	} else {
		modalRef.current = new ModalStore().getDetail();
	}

	return [modalRef.current];
};

export default useModal;
